﻿using System;
using System.Configuration;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Unity.Configuration;

namespace BlueSky
{
    /// <summary>
    /// Unity container factory.
    /// </summary>
    public class UnityContainerFactory
    {
        /// <summary>
        /// Return Unity container object.
        /// </summary>
        /// <returns>Unity container.</returns>
        public IUnityContainer Get()
        {
            return new UnityContainer();
        }

        /// <summary>
        /// Return Unity container object.
        /// </summary>
        /// <param name="sectionName">The configuration section path and name.</param>
        public IUnityContainer Get(string sectionName)
        {
            IUnityContainer container = Get();
            UnityConfigurationSection section = (UnityConfigurationSection)ConfigurationManager.GetSection(sectionName);
            section.Containers.Default.Configure(container);
            return container;
        }
    }
}
